package com.itheima.String;

import java.util.Scanner;

public class Demo05Login {
    public static void main(String[] args) {
        String root = "root";
        String password = "root";
        Scanner sc = new Scanner(System.in);

        for (int i = 1; i <= 3; i++) {
            System.out.println("请输入用户名:");
            String name = sc.nextLine();
            System.out.println("请输入密码:");
            String pass = sc.nextLine();
            if (name.equals(root) && pass.equals(password)) {//equals
                System.out.println("登陆成功!");
                break;
            } else {
                if (i == 3) {
                    System.out.println("今日以毕,明日再来!");
                } else {
                    System.out.println("请重新输入,这是你第" + (3 - i) + "次机会");
                }
            }
        }
    }
}
